/**设置界面树形菜单*/
var setting = {
	view: {
		selectedMulti: false
	},
	check: {
		enable: true
	},
	edit: {
		enable: true,
		showRemoveBtn: false,
		showRenameBtn: false
	},
	data: {
		keep: {
			parent:true,
			leaf:true
		},
		simpleData: {
			enable: true
		}
	}
};
function saveDataRights(){
	//$('#myModal').modal('show');
	var loginid=$("#loginid").val();
	var menuTree = $.fn.zTree.getZTreeObj("menup");
	var menudata=menuTree.getCheckedNodes();
	var dataTree = $.fn.zTree.getZTreeObj("datap");
	var datadata=dataTree.getCheckedNodes();
	var menus="";
	var data=""
	$.each(menudata,function(i,menu){
		menus=menus+menu.id+"!";
	});
	$.each(datadata,function(i,menu){
		data=data+menu.id+"!";
	});
	$.post("../system/savePermission_User.action",{"loginid":loginid,"menuData":menus,
		"dataRights":data}, function(result) {
		if(result.msg=="succ"){
			$('#myModal').modal('hide');
			$("#alertinfo").html("用户权限维护成功.");
			$('#myinfo').modal('show');
		}else{
			$('#myModal').modal('hide');
			$("#alertinfo").html(result.msg);
			$('#myinfo').modal('show');
		}
	});
	
};
$(document).ready(function(){
	var loginid=$("#loginid").val();
    $.post("../system/queryUser_Permission.action",{"loginid":loginid},function(result){
    	$.fn.zTree.init($("#menup"), setting, result.menus);
    });
    $.post("../system/query_DataRights.action",{"loginid":loginid},function(result){
    	$.fn.zTree.init($("#datap"), setting, result.rights);
    });
});